package com.zcn.io.web.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zcn.io.common.pojo.CommonResult;
import com.zcn.io.web.api.entity.OrderPayAgentDetailVo;
import com.zcn.io.web.api.query.AnswerStatisticQuery;
import com.zcn.io.common.query.PayDetailStatisticsQuery;
import com.zcn.io.common.vo.OrderMainForTrusteeshipVo;
import com.zcn.io.common.vo.statisticsVo.OrderPayDetailStatisticsMainVo;
import com.zcn.io.web.service.StatisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @desc: 数据统计模块
 * @author: 202438 邱建伟
 * @date: 2024/9/28 17:28
 * @Copyright (c) 2024, All Rights Reserved
 */
@RestController
@RequestMapping("/statistics")
public class StatisticsController {

    @Autowired
    private StatisticsService statisticsService;


    @PostMapping("/payDetailStatisticsAll")
    @PreAuthorize("hasAnyAuthority('super_man')")
    public CommonResult<OrderPayDetailStatisticsMainVo> payDetailStatisticsAll(@RequestBody PayDetailStatisticsQuery query) {
        return CommonResult.success(statisticsService.payDetailStatisticsAll(query));
    }

    /**
    * @desc:  获取代理商支付明细
    * @author 202438 邱建伟
    * @date 2024/11/3 15:14
    */
    @GetMapping("/getAgentPayDetail")
    public CommonResult<List<OrderPayAgentDetailVo>> getAgentPayDetail(PayDetailStatisticsQuery query) {
        return CommonResult.success(statisticsService.getAgentPayDetail(query));
    }

    @GetMapping("/getAnswerStatics")
    public CommonResult<Page<OrderMainForTrusteeshipVo>> getAnswerStatics(Page<OrderMainForTrusteeshipVo> page, AnswerStatisticQuery query) {
        return CommonResult.success(statisticsService.getAnswerStatics(page, query));
    }
}
